<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
    <title>任务列表</title>
    
	<script type="text/javascript">
	function del(id){
		$.get("<%=basePath%>tbSystemJob/delTbSystemJob?id=" + id,function(data){
			if("success" == data.result){
				alert("删除成功");
				window.location.reload();
			}else{
				alert("删除失败");
			}
		});
	}
	function startJob(id){
		$.get("<%=basePath%>tbSystemJob/startJob?id=" + id,function(data){
			if("success" == data.result){
				alert("启动成功");
				window.location.reload();
			}else{
				alert("启动失败");
			}
		});
	}
	function stopJob(id){
		$.get("<%=basePath%>tbSystemJob/stopJob?id=" + id,function(data){
			if("success" == data.result){
				alert("停止成功");
				window.location.reload();
			}else{
				alert("停止失败");
			}
		});
	}
</script>
  </head>
  
  <body>
    <h6><a href="<%=basePath%>tbSystemJob/toAddTbSystemJob">添加任务</a></h6>
	<table border="1">
		<tbody>
			<tr>
				<th>jobName</th>
				<th>jobDescript</th>
				<th>jobClass</th>
				<th>jobCron</th>
				<th>jobStatus</th>
				<th>操作</th>
			</tr>
			<c:if test="${!empty tbSystemJobList }">
				<c:forEach items="${tbSystemJobList}" var="tbSystemJob">
					<tr>
						<td>${tbSystemJob.jobName }</td>
						<td>${tbSystemJob.jobDescript }</td>
						<td>${tbSystemJob.jobClass }</td>
						<td>${tbSystemJob.jobCron }</td>
						<td>${tbSystemJob.jobStatus }</td>
						<td>
							<a href="<%=basePath%>tbSystemJob/getTbSystemJob?id=${tbSystemJob.id}">编辑</a>
							<a href="javascript:stopJob('${tbSystemJob.id }')">停止</a>
							<a href="javascript:startJob('${tbSystemJob.id }')">启动</a>
							<a href="javascript:del('${tbSystemJob.id }')">删除</a>
						</td>
					</tr>				
				</c:forEach>
			</c:if>
		</tbody>
	</table>
  </body>
</html>
